<include file="../Public/_header.html" />
<div class="so_main">
<php>
	//dump($pagedata);
</php>
  
			<!-------- 搜索开始 -------->
		  <div id="search_div" rel='0'>
		  	<div class="page_tit">
		  		搜索礼券[ <a href="javascript:void(0);" onclick="_show_searcharea();">隐藏</a> ]
		  	</div>
				
				<div class="sform">
					<form method="post" action="{:U('/Order/coupon')}" id="searchForm">
						<input id="pno" name="pno" type="hidden" value="1">
						<dl>
					    	
					      	<span>订单编号：</span>
					        <input id="search_orderId" name="search_orderId" type="text" value="{$search_orderId}">
					      
					      	<span>商品券码：</span>
					    	<input name="search_passcode" id="search_passcode" type="text" value="{$search_passcode}">
							
							<span>接收手机：</span>
						    <input id="search_receiver_mobile" name="search_receiver_mobile" type="text" value="{$search_receiver_mobile}">

					    </dl>	
					    <dl>
					    	
					        <span>是否激活：</span>
					      	<input name="search_is_active" type="radio" value="all" <eq name="search_is_active" value="all">checked</eq>>全部
					        <input name="search_is_active" type="radio" value="Y" <eq name="search_is_active" value="Y">checked</eq>>是
					        <input name="search_is_active" type="radio" value="N" <eq name="search_is_active" value="N">checked</eq>>否
					        
					        <span>是否过期：</span>
					      	<input name="search_is_expired" type="radio" value="all" <eq name="search_is_expired" value="all">checked</eq>>全部
					        <input name="search_is_expired" type="radio" value="Y" <eq name="search_is_expired" value="Y">checked</eq>>是
					        <input name="search_is_expired" type="radio" value="N" <eq name="search_is_expired" value="N">checked</eq>>否
					        
					    	<span>是否使用：</span>
					      	<input name="search_is_used" type="radio" value="all" <eq name="search_is_used" value="all">checked</eq>>全部
					        <input name="search_is_used" type="radio" value="Y" <eq name="search_is_used" value="Y">checked</eq>>是
					        <input name="search_is_used" type="radio" value="N" <eq name="search_is_used" value="N">checked</eq>>否
					        
					        <span>发送状态：</span><!-- enum('Y','N','P','E') -->
					      	<input name="search_is_send" type="radio" value="all" <eq name="search_is_send" value="all">checked</eq>>全部
					        <input name="search_is_send" type="radio" value="Y" <eq name="search_is_send" value="Y">checked</eq>>已发
					        <input name="search_is_send" type="radio" value="N" <eq name="search_is_send" value="N">checked</eq>>未发
					        <input name="search_is_send" type="radio" value="E" <eq name="search_is_send" value="E">checked</eq>>失败
					    </dl>
					    <dl>
					    	<input type="submit" class="btn_b" value="搜索" />
					    	&nbsp;&nbsp;&nbsp;&nbsp;
					    	<input type="reset" class="btn_b" value="清空" />
					    </dl>
					</form>
					<div class="clear"></div>
			  </div>
		  </div>
		  <!-------- 搜索结束 -------->
		  
  <div class="page_tit">礼券管理</div>
  <div class="Toolbar_inbox">
  		<a href="javascript:void(0);" class="btn_a" onclick="_show_searcharea();">
			<span>条件搜索</span>
		</a>
  </div>
  
  <div class="list">
  <table id="partner_list" width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
  	<th class="line_l" style="text-align:center">取消/激活</th>
    <th class="line_l">订单编号</th>
    <th class="line_l">商品名称</th>
    <th class="line_l">商品数量</th>
    <th class="line_l">接收号码</th>
    <th class="line_l">发送方式</th>

    <th class="line_l">预定发送</th>
    <th class="line_l">发送时间</th>
    <th class="line_l">有限期</th>
    
    <th class="line_l">发送状态</th>
    <th class="line_l">是否支付</th>
    <th class="line_l">使用状态</th>
    <th class="line_l" style="text-align:center">操作</th>
  </tr>
  	<php>
  		if(!empty($pagedata)&&!empty($pagedata['data'])){
			foreach($pagedata['data'] as $vo1){
				if(!in_array($vo1['order_id'],$ary_orderid))$ary_orderid[]=$vo1['order_id'];
			}
			if(!empty($ary_orderid))$ordersInfo = service('Order')->selectORelInfoByIds($ary_orderid);
			//dump($ordersInfo);
		}
	</php>
  <volist id="vo" name="pagedata['data']">
  <php>$_tmp_copnstatus = getSendStatus($vo);</php>
      <tr overstyle='on' id="partner_{$vo.id}">
      	<td style="text-align:center;color:red">{$vo.is_canceled}&nbsp;&nbsp;/&nbsp;&nbsp;{$vo.is_active}</td>
        <td><a href="{:U('/Order/index',array('search_orderId'=>$vo['order_id']))}" >{$vo.order_id}</a></td>
        
        <td>{$ordersInfo[$vo['order_id']]['goods_title']}</td>
        <td>{$vo['quantity']}</td>
        
        <td>{$vo['receiver_mobile']}</td>
        <td>{:getChanelDesc($vo['channel'])}</td>
        <td>{$_tmp_copnstatus['target_time']}</td>
        <td>{:paramMillisecond2Date($vo['sendtime'],'Y-m-d H:i','-------- --:--')}</td>
        <td>{:paramMillisecond2Date($vo['expired_date'],'Y-m-d H:i','-------- --:--')}</td>
        
        <td>
			<img 	src="/Public/Images/global/{$_tmp_copnstatus['icon']}" 
				id='send_state_{$data_['id']}'	title="{$_tmp_copnstatus['desc']}" >
		</td>
        <td>{$ordersInfo[$vo['order_id']]['pay_state']}</td>
        <td><span title="使用时间：{:paramMillisecond2Date($vo['check_time'],'Y年m月d日 H:i','未使用')}"><php>echo ifCouponUsed($vo['checker_id'],$vo['check_time'])?"已使用":"未使用";</php></span></td>
        <td style="text-align:center">
        	<a href="{:U('/Order/couponDetail',array('passcode'=>$vo['passcode']))}" >详情</a>
        	&nbsp;
        	<a callback="_tmp_docouponconfirm()" 
				href="javascript:void(0);" onclick="ui.confirm(this,'请谨慎使用该操作，该操作不可逆。<br>如果出错将很麻烦。确定使用么？');">确认使用</a>
        	
        </td>
      </tr>
  </volist>
  </table>
  </div>
  <div class="Toolbar_inbox">
    <div class="page_box">{$pagedata['html']}</div>
  </div>
</div>
<input type="hidden" id="temp_partnerdesc">
<input type="hidden" id="temp_partner_id">
<input type="hidden" id="temp_codevalue">
<script>
    //鼠标移动表格效果
    $(document).ready(function(){
    	table_init();
    });
    
    function _tmp_docouponconfirm(){
    	$('#temp_partner_id').val('');$('#temp_partnerdesc').val('');$('#temp_codevalue').val('{$vo['passcode']}');
		k_pop_syncSearch('temp_partner_id','temp_partnerdesc','选择验证商户','{:U('Admin://Partner/getJson')}'
						,function(){ ui.box.close();ui.box.show( getdialoghtml( $('#temp_partnerdesc').val(),$('#temp_codevalue').val() ),{title:'确认验证礼券'} ); }
						,function(){ $('#temp_partner_id').val('');$('#temp_partnerdesc').val('');$('#temp_codevalue').val(''); });
    }
    
    
    function doconfirm(){
    	$.kajax({      
    		ajx_rtn_type:'JSON',
    		url:"{:U('Admin://Order/ajxCouponUsed')}",      
    		type:'post', //数据发送方式  
    		data:{codevalue:$('#temp_codevalue').val(),checker_id:$('#temp_partner_id').val()} ,    
    		async: false ,//同步方式     
    		success: function(jsonobj){ 
    			//alert(jsonobj.status+jsonobj.msg);
    			if(jsonobj.status==1){
    				k_success('商品券兑换成功！');
    			}else{
    				k_error('商品券兑换失败！');
    			}
    		}
    	});
    }
    function getdialoghtml(temp_partnerdesc,temp_codevaluedesc){
    	var html_ = '<div style="width:300px;" class="pop_form alL" id="">'
						+'<div class="c"></div>'
						+'<div class="pop_form_li">'
						+'<div style="text-align: left; margin:10px 20px">'
						+'商户：<input type="text" value="'+temp_partnerdesc+'" id="" style="width:210px" name="" readonly>'
						+'<br><br>'
						+'券码：<input type="text" value="'+temp_codevaluedesc+'" id="" style="width:210px" name="" readonly>'
						+'</div>'
						+'</div>'
						+'<div class="c"></div>'
						+'<div class="answers">'
						+'<input type="button" class="btn_ok" onclick="doconfirm()" value="确定" id="k_confirm_btn">'
						+'</div>'
						+'</div>';
		return html_;
    }
</script>

<include file="../Public/_footer.html" />